<?php
	session_start();
	include "../db.php";
	$err = 0; // To check whether or not any error is there in input or not.
	$username = $_SESSION['username'];
	if(!isset($_SESSION['username'])) header("location:../login/login.php?msg=line_6"); /* Checks whether or not session is activated */
	else if($_SESSION['username']=="") header("location:../login/login.php?msg=line_7");
	
	$referer = $_SERVER['HTTP_REFERER'];			/* 	Checks whether or not the file is */
	$ref = explode("/",$_SERVER['HTTP_REFERER']);	/* 	called from valid location or not */
	end($ref);										/* 						*/
	$ref1 = $ref[key($ref)];						/* 						*/
	if(strpos($referer,"create_industry_problem.php")<0) {					/* 						*/
		session_destroy();							/* 						*/
		header("location:../login/login.php?msg=line_15");		/* 						*/
	}	
	extract($_POST);
	if($problem_name=="" || $problem_description=="" || $industry_name=="") {
		header("location:$referer?msg=fill_all_details");
	}
	$date = date("Y-m-d");
	/* INSERT DATA IN PROBLEM TABLE...*/
	$add_problem_query = "insert into problem(statement,description,file_path,doc,type,approved,leader_id,added_by,more_detail,taken) values
										('$problem_name','$problem_description','','$date','IDP','0','','$username','0','0')";
	$add_problem_rs = mysql_query($add_problem_query);
	if(!$add_problem_rs) {
		echo mysql_error();
		$err = 1;
	}
	
	if($err == 0) header("location:all_industry_problem.php?username=$username");
	else echo "Some Error!!!";
?>